package com.pwt.controller.basicsetting;

import com.pwt.annotation.Update;
import com.pwt.common.CustomException;
import com.pwt.common.ResultPage;
import com.pwt.entity.ProductFeature;
import com.pwt.entity.ProductManage;
import com.pwt.model.ProductManageModel;
import com.pwt.service.ProductManageService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/8/31
 */
@RestController
@Tag(name = "设置-产品管理")
public class ProductManageController {

    private ProductManageService productManageService;

    /**
     * 构造注入
     * @param productManageService
     */
    public ProductManageController(ProductManageService productManageService){
        this.productManageService = productManageService;
    }
    @Hidden
    @GetMapping("products")
    @Operation(description = "产品管理列表",summary = "产品管理列表")
    @Parameters({
            @Parameter(name = "name",description = "零件名称",required = false),
            @Parameter(name = "limit",description = "展示数",required = true),
            @Parameter(name = "page",description = "分页数",required = true)
    })
    public ResultPage  getList(@RequestParam(value = "name",required = false) String name, @RequestParam(value = "page",required = true) Integer page,
                               @RequestParam(value = "limit",required = true) Integer limit){
        return this.productManageService.getList(name,page,limit);
    }

    @Hidden
    @PutMapping("product")
    @Operation(description = "修改产品颜色",summary = "修改产品颜色")
    @Parameters({
            @Parameter(name = "teteil",description = "零件id",required = false),
            @Parameter(name = "color",description = "属性颜色",required = false)
    })
    public ProductManage  update(Integer teteil,String color) throws CustomException {
        return this.productManageService.update( teteil, color);
    }
}
